package com.thinkingstar.iads.datacenter.controller;

import java.util.List;
import java.util.Map;
import javax.jcr.query.Query;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.thinkingstar.iads.datacenter.entity.*;

import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.xmlbeans.impl.xb.xsdschema.impl.PublicImpl;
import org.eclipse.jetty.client.RequestNotifier;
import org.nutz.dao.Dao;
import org.nutz.dao.QueryResult;
import org.nutz.dao.pager.Pager;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.By;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.GET;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.POST;
import org.nutz.mvc.annotation.Param;
import com.thinkingstar.iads.common.filter.GlobalsFilter;
import com.thinkingstar.iads.common.filter.UserLoginFilter;
import com.thinkingstar.iads.common.jsonUtils.AjaxResult;
import com.thinkingstar.iads.cs.sys.enumerate.CODE_TYPE;
import com.thinkingstar.iads.datacenter.entity.dao.DaoDcCRHInfo;
import com.thinkingstar.iads.datacenter.entity.dao.DaoDcCrhAttach;
import com.thinkingstar.iads.datacenter.entity.dao.DaoDcFormField;
import com.thinkingstar.iads.datacenter.entity.dao.DaoDcMileageLibrary;
import com.thinkingstar.iads.datacenter.service.DataDesignManagerServiceI;
import com.thinkingstar.iads.datacenter.serviceImpl.DataDesignManagerServiceImpl;

/**
 * 数据中心相关
 * @author Administrator
 *
 */
@IocBean
@At("/dataCenter/businessdata")
//@RequiresPermissions(value = {"编辑:eqEdit","查看:eqView"},logical=Logical.OR)
//@RequiresRoles(value = {"admin","系统管理","设计人员"},logical=Logical.OR)
@Filters({ @By(type = GlobalsFilter.class) , @By(type = UserLoginFilter.class)})
public class BusinessDataManagerController {
	
	private static Log log = Logs.get();
	
	@Inject DataDesignManagerServiceImpl dataDesignManagerServiceImpl;
	
	@Inject DaoDcFormField daoDcFormField;
	
	@Inject DaoDcCrhAttach daoDcCrhAttach;
	
	@Inject DaoDcCRHInfo daoDcCRHInfo;
	
	@Inject DaoDcMileageLibrary daoDcMileageLibrary;	
	/**
	 * 查询项目阶段
	 * @param nutMap
	 */
	@At({"/findDesignPhaseData"})
	@Ok("json:full")
	public QueryResult findProjectDesignPhase(@Param("..") NutMap nutMap) {
		return dataDesignManagerServiceImpl.findProjectDesignPhaseAndPageInfo(nutMap);
	}
	
	/**
	 * 更新项目阶段
	 * @param dcProjectDesignPhase
	 * @return
	 */
	@At("/updateDesignPhase")
	@Ok("json")
	public AjaxResult updateDesignPhase(@Param("..") DcProjectDesignPhase dcProjectDesignPhase){
		return dataDesignManagerServiceImpl.updateDesignPhase(dcProjectDesignPhase);
	}
	
	/**
	 * 根据主键删除项目设计阶段
	 * @param id
	 * @return
	 */
	@At("/delDesignPhaseById")
	@Ok("json")
	public AjaxResult delDesignPhaseById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcProjectDesignPhase.class, id);
	}
	
	/**
	 * 根据条件查询设计专业信息
	 * @param nutMap
	 * @return
	 */
	@At({"/findDesignMajorData"})
	@Ok("json:full")
	public QueryResult findProjectDesignMajor(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findProjectDesignMajor(nutMap);
	}
	
	/**
	 * 查询已匹配以及未匹配的专业
	 * @param content_id
	 * @return
	 */
	@At("/findMatchingMajorList")
	@Ok("json:full")
	public List <Map> findMatchingMajorByContentId(@Param("content_id") String content_id){
		return dataDesignManagerServiceImpl.findMatchingMajorByContentId(content_id);
	}
	
	
	/**
	 * 更新项目设计专业
	 * @param dcProjectDesignMajor
	 * @return
	 */
	@At("/updateDesignMajor")
	@Ok("json:full")
	public AjaxResult updateDesignMajor(@Param("..") DcProjectDesignMajor dcProjectDesignMajor){
		return dataDesignManagerServiceImpl.updateDesignMajor(dcProjectDesignMajor);
	}
	
	/**
	 * 根据主键删除项目设计专业
	 * @param id
	 * @return
	 */
	@At("/delDesignMajorById")
	@Ok("json")
	public AjaxResult delDesignMajorById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcProjectDesignMajor.class, id);
	}
	
	/**
	 * 分页查询设计内容
	 * @param nutMap
	 * @return
	 */
	@At("/findDesignContent")
	@Ok("json:full")
	public QueryResult findDesignContent(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findDesignContent(nutMap);
	}
	
	/**
	 * 查询设计内容匹配资料信息
	 * @param nutMap
	 * @return
	 */
	@At("/findContentMatchingMentions")
	@Ok("json:full")
	public List<Map> findContentMatchingMentions(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findContentMatchingMentions(nutMap);
	}
	
	/**
	 * 逻辑删除设计内容
	 * @param id
	 * @return
	 * @throws Exception 
	 */
	@At("/delDesignContentById")
	@Ok("json")
	public AjaxResult delDesignContentById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcProjectDesignContent.class, id);
	}
	
	/**
	 * 更新设计内容
	 * @param dcProjectDesignContent
	 * @return
	 */
	@At("/updateDesignContent")
	@Ok("json")
	public AjaxResult updateDesignContent(@Param("..") DcProjectDesignContent dcProjectDesignContent){
		return dataDesignManagerServiceImpl.updateDesignContent(dcProjectDesignContent);
	}
	
	
	/**
	 * 新建生产者(专业)与消费者(设计内容)关联关系
	 * @param nutMap
	 * @return
	 * @throws Exception 
	 */
	@At("/addDesignContentCorrelationMajor")
	@Ok("json")
	public AjaxResult addDesignContentCorrelationMajor(@Param("..") Map <String , Object> nutMap){
		return dataDesignManagerServiceImpl.addDesignContentCorrelationMajor(nutMap);
	}
	
	/**
	 * 根据条件分页查询提入资料信息
	 * @return
	 */
	@At("/findMentionsPageListByCondition")
	@Ok("json:full")
	public QueryResult findMentionsPageList(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findMentionsPageListByCondition(nutMap);
	}
	
	/**
	 * 逻辑删除提入资料
	 * @param id
	 * @return
	 */
	@At("/delMentionById")
	@Ok("json")
	public AjaxResult delMentionById(@Param("id") String id , @Param("code") String code){
		return dataDesignManagerServiceImpl.delMentionById(id,code);
	}
	
	//删除设计单元信息
	@At("/delDesignCellById/?/?")
	@Ok("json")
	public AjaxResult delDesignCellById(String id , String code){
		return dataDesignManagerServiceImpl.delDesignCellById(id, code);
	}
	
	/**
	 * 更新提入资料
	 * @param dcProjectMentionInformation
	 * @return
	 */
	@At("/updateMentionsInfo")
	@Ok("json")
	public AjaxResult updateMentionsInfo(@Param("..") DcProjectMentionInformation dcProjectMentionInformation){
		return dataDesignManagerServiceImpl.updateMentionsInfo(dcProjectMentionInformation);
	}
	
	/**
	 * 根据专业id以及设计内容id,项目设计阶段id查询已匹配和未匹配资料
	 * @param nutMap
	 * @return
	 */
	@At("/findMentionsByCondition")
	@Ok("json")
	public List<Map> findMentionsByMajorId(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findMentionsByMajorId(nutMap);
	}
	
	/**
	 * 匹配设计内容下的专业资料
	 * @param nutMap
	 * @return
	 */
	@At("/addMentionsByDesignContent")
	@Ok("json")
	public AjaxResult addMentionsByDesignContent(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.addMentionsByDesignContent(nutMap);
	}
	
	/**
	 * 查询设备父类型
	 * @param nutMap
	 * @return
	 */
	@At("/findEquipmentType")
	@Ok("json:full")
	public QueryResult findEquipmentType(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findEquipmentType(nutMap);
	}
	
	
	/**
	 * 删除设备类型
	 * @param id
	 * @return
	 */
	@At("/delEquipmentTypeById")
	@Ok("json")
	public AjaxResult delEquipmentTypeById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcEquipmentType.class, id);
	}
	
	/**
	 * 更新设备类型
	 * @param dcEquipmentType
	 * @return
	 */
	@At("/updateEquipmentType")
	@Ok("json")
	public AjaxResult updateEquipmentType(@Param("..") DcEquipmentType dcEquipmentType){
		return dataDesignManagerServiceImpl.updateEquipmentType(dcEquipmentType);
	}
	
	/**
	 * 分页查询设备厂商信息
	 * @return
	 */
	@At("/findManufacturerPageList")
	@Ok("json:full")
	public QueryResult findManufacturerPageList(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findManufacturerPageList(nutMap);
	}
	
	/**
	 * 更新厂商
	 * @return
	 */
	@At("/updateManufacturer")
	@Ok("json")
	public AjaxResult updateManufacturer(@Param("..") DcEquipmentManufacturer dcEquipmentManufacturer){
		return dataDesignManagerServiceImpl.updateEquipmentManufacturer(dcEquipmentManufacturer);
	}
	
	/**
	 * 删除厂商
	 * @param id
	 * @return
	 */
	@At("/delManufacturerById")
	@Ok("json")
	public AjaxResult delManufacturerById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcEquipmentManufacturer.class, id);
	}
	
	/**
	 * 分页查询设备信息
	 * @param nutMap
	 * @return
	 */
	@At("/findEquipmentPageList")
	@Ok("json:full")
	public QueryResult findEquipmentPageList(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findEquipmentPageList(nutMap);
	}
	
	/**
	 * 更新设备信息
	 * @return
	 */
	@At("/updateEquipment")
	@Ok("json:full")
	public AjaxResult updateEquipment(@Param("..") DcEquipment dcEquipment){
		return dataDesignManagerServiceImpl.updateEquipment(dcEquipment);
	}
	
	/**
	 * 根据id删除设备
	 * @param id
	 * @return
	 */
	@At("/delEquipmentById")
	@Ok("json")
	public AjaxResult delEquipmentById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcEquipment.class,id);
	}
	
	/**
	 * 获取厂商设备
	 * @param nutMap
	 * @return
	 */
	@At("/findManufacturerEquipmentPageList")
	@Ok("json:full")
	public QueryResult findManufacturerEquipmentPageList(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findManufacturerEquipmentPageList(nutMap);
	}
	
	//更加设备查询生产此设备的厂商
	@At("/findManufacturerListByEquipmentId")
	@Ok("json:full")
	public List<NutMap> findManufacturerListByEquipmentId(@Param("equipment_id") String equipment_id){
		return dataDesignManagerServiceImpl.findManufacturerListByEquipmentId(equipment_id);
	}
	
	/**
	 * 更新厂商设备
	 * @param dcManufacturerEquipment
	 * @return
	 */
	@At("/updateManufacturerEquipment")
	@Ok("json")
	public AjaxResult updateManufacturerEquipment(@Param("..") DcManufacturerEquipment dcManufacturerEquipment){
		return dataDesignManagerServiceImpl.updateManufacturerEquipment(dcManufacturerEquipment);
	}
	
	/**
	 * 删除厂商设备
	 * @param id
	 * @return
	 */
	@At("/delManfacturerEquipmentById")
	@Ok("json")
	public AjaxResult delManfacturerEquipmentById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcManufacturerEquipment.class, id);
	}
	
	/**
	 * 获取某个表的字段信息
	 * @param table_name
	 * @return
	 */
	@At("/findFromFieldList/?")
	@Ok("json")
	public List <NutMap> findFromFieldList(String table_name){
		return dataDesignManagerServiceImpl.findFieldWidgetByTableName(table_name);
	}
	
	/**
	 * 更新表结构
	 * @return
	 */
	@At("/updateTableField")
	@Ok("json")
	public AjaxResult updateTableField(@Param("table_name") String table_name , @Param("data_list") String data_list){
		return dataDesignManagerServiceImpl.updateTableField(table_name, data_list);
	}
	
	/**
	 * 查询设计常量版本库
	 * @return
	 */
	@At("/findDesignConstantVersion")
	@Ok("json:full")
	public QueryResult findDcDesignConstantVersion(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findDcDesignConstantVersion(nutMap);
	}

	/**
	 * 查询设计常量版本库(按照设计阶段，设计内容，所属专业查询 下拉用)
	 * @return
	 */
	@At("/findConstantVersionList")
	@Ok("json:full")
	public List<DcProjectDesignConstantVersion> findConstantVersionList(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findConstantVersionList(nutMap);
	}

	/**
	 * 查询设计公式版本库(按照设计阶段，设计内容，所属专业查询 下拉用)
	 * @return
	 */
	@At("/findFormulaVersionList")
	@Ok("json:full")
	public List<DcProjectDesignFormulaVersion> findFormulaVersionList(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findFormulaVersionList(nutMap);
	}


	//删除常量版本库
	@At("/delDesignConstantById")
	@Ok("json")
	public AjaxResult delDesignConstantById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delDesignConstantById(id);
	}
	
	//编辑常量版本库
	@At("/updateConstantVersion")
	@Ok("json")
	public AjaxResult updateConstantVersion(@Param("..") DcProjectDesignConstantVersion dcProjectDesignConstantVersion){
		return dataDesignManagerServiceImpl.updateConstantVersion(dcProjectDesignConstantVersion);
	}
 	
	//常量集
	@At("/findConstantInfoListById/?")
	@Ok("beetl:/projectRoot/dcCenter/constant/projectDesignConstantInfo.html")
    public NutMap findConstantInfoListById(String constant_version_id){
    	NutMap nutMap = new NutMap();
    	nutMap.setv("constant_version_id", constant_version_id);
    	return nutMap;
    }
	
	//公式集
	@At("/findFormulaInfoListById/?")
	@Ok("beetl:/projectRoot/dcCenter/formula/projectDesignFormulaInfo.html")
	public NutMap findFormulaInfoListById(String formula_version_id){
    	NutMap nutMap = new NutMap();
    	nutMap.setv("formula_version_id", formula_version_id);
    	return nutMap;
	}
	
	//查询常量集
	@At("/findConstantInfoList")
	@Ok("json:full")
	public QueryResult findConstantInfoList(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findConstantInfoListById(nutMap);
	}
	
	//查询公式集
	@At("/findFormulaInfoList")
	@Ok("json:full")
	public QueryResult findFormulaInfoList(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findFormulaInfoList(nutMap);
	}
	
	//更新常量集
	@At("/updateConstant")
	@Ok("json")
	public AjaxResult updateConstant(@Param("..") DcProjectDesignConstant dcProjectDesignConstant , HttpSession session){
		return dataDesignManagerServiceImpl.updateConstantInfo(dcProjectDesignConstant, session);
	}
	
	//删除常量集
	@At("/delConstantInfoList")
	@Ok("json")
	public AjaxResult delConstantInfoList(@Param("id") String id){
		return dataDesignManagerServiceImpl.delConstantInfoById(id);
	}
	
	
	//公式库查询
	@At("/findFormulaVersion")
	@Ok("json:full")
	public QueryResult findFormulaVersion(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findFormulaVersion(nutMap);
	}
	
	//更新公式版本库
	@At("/updateFormulaVersion")
	@Ok("json")
	public AjaxResult updateFormulaVersion(@Param("..") DcProjectDesignFormulaVersion dcProjectDesignFormulaVersion){
		return dataDesignManagerServiceImpl.updateFormulaVersion(dcProjectDesignFormulaVersion);
	}
	
	//删除公式版本库
	@At("/delFormulaVersionById")
	@Ok("json")
	public AjaxResult delFormulaVersionById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcProjectDesignFormulaVersion.class, id);
	}
	
	//删除公式
	@At("/delFormulaDataById")
	@Ok("json")
	public AjaxResult delFormulaDataById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcProjectDesignFormulaData.class, id);
	}
	
	//更新公式
	@At("/updateFormulaData")
	@Ok("json")
	public AjaxResult updateFormulaData(@Param("..") DcProjectDesignFormulaData dcProjectDesignFormulaData){
		return dataDesignManagerServiceImpl.updateFormulaData(dcProjectDesignFormulaData);
	}
	
	//获取所有上级数据项
	@At("/findParentConstant")
	@Ok("json:full")
	public List <DcProjectDesignConstant> findParentConstant(@Param("constant_version_id") String constant_version_id){
		return dataDesignManagerServiceImpl.findParentConstant(constant_version_id);
	}
	
	//查询设计单元所有表单项
	@At("/findDesignCellInfo")
	@Ok("json:full")
	public QueryResult findDesignCellInfo(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findDesignCellList(nutMap);
	}
	
	//查询设计单元组
	@At("/findDesignCellGroups")
	@Ok("json:full")
	public QueryResult findDesignCellGroups(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findDesignCellGroups(nutMap);
	}
	
	
	//更新设计单元
	@At("/updateDesignCellInfo")
	@Ok("json")
	public AjaxResult updateDesignCellInfo(DcProjectDesignCell dcProjectDesignCell){
		return dataDesignManagerServiceImpl.updateDesignCellInfo(dcProjectDesignCell);
	}

	//更新设计单元 对应的 公式计算规则路径
	@At("/updateDesignCellUrulePath")
	@Ok("json")
	public AjaxResult updateDesignCellUrulePath(DcProjectDesignCell dcProjectDesignCell){
		return dataDesignManagerServiceImpl.updateDesignCellUrulePath(dcProjectDesignCell);
	}


	//更新设计单元 对应的 公式计算规则路径
	@At("/updateDesignCellFormulaAndConstant")
	@Ok("json")
	public AjaxResult updateDesignCellFormulaAndConstant(DcProjectDesignCell dcProjectDesignCell){
		return dataDesignManagerServiceImpl.updateDesignCellFormulaAndConstant(dcProjectDesignCell);
	}
	
	//查询表单控件
	@At("/findFieldWidgetByTableName")
	@Ok("json:full")
	public List<NutMap> findFieldWidgetByTableName(@Param("table_name") String table_name){
		return dataDesignManagerServiceImpl.findFieldWidgetByTableName(table_name);
	}
	
	//查询子设备类型
	@At("/findEquipmentCidTypeList")
	@Ok("json:full")
	public QueryResult findEquipmentCidTypeList(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findEquipmentChildrenType(nutMap);
	}
	 
	//更新设备子类型
	@At("/updateEquipmentCidType")
	@Ok("json")
	public AjaxResult updateEquipmentCidType(@Param("..") DcEquipmentChildrenType dcEquipmentChildrenType){
		return dataDesignManagerServiceImpl.updateEquipmentCidType(dcEquipmentChildrenType);
	}
	
	//根据id删除设备子类型
	@At("/delEquipmentCidById")
	@Ok("json")
	public AjaxResult delEquipmentCidById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcEquipmentChildrenType.class, id);
	}
	
	//更新设备属性
	@At("/updateEquipmentInfo")
	@Ok("json")
	public Object updateEquipmentInfo(@Param("..") DcManufacturerEquipmentField dcManufacturerEquipmentField){
		return dataDesignManagerServiceImpl.updateEquipmentInfo(dcManufacturerEquipmentField);
	}
	

/*	@At("/findEquipmentProperty")
	@Ok("json")
	public Object findEquipmentProperty(@Param("equipment_id") String equipment_id){
		return dataDesignManagerServiceImpl.findEquipmentProperty(equipment_id);
	}*/
	
	//查询设备配备库
	@At("/findEquipmentEquipList")
	@Ok("json:full")
	public QueryResult findEquipmentEquipList(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findEquipmentEquip(nutMap);
	}
	
	//删除设备配备
	@At("/delEquipmentEquipById")
	@Ok("json")
	public AjaxResult delEquipmentEquipById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcEquipmentEquip.class, id);
	}
	
	//更新设备配备库
	@At("/updateEquipmentEquip")
	@Ok("json")
	public AjaxResult updateEquipmentEquip(@Param("..") DcEquipmentEquip dcEquipmentEquip){
		return dataDesignManagerServiceImpl.updateEquipmentEquip(dcEquipmentEquip);
	}
	
	//更新设备配备信息
	@At("/updateEquipmentEquipInfo")
	@Ok("json")
	public AjaxResult updateEquipmentEquipInfo(@Param("..") DcEquipmentEquipInfo dcEquipmentEquipInfo){
		return dataDesignManagerServiceImpl.updateEquipmentEquipInfo(dcEquipmentEquipInfo);
	}
	
	//设备配备详细信息
	@At("/equipmentEquipInfo/?")
	@Ok("beetl:/projectRoot/dcCenter/equipment/projectEquipmentEquipInfo.html")
	public NutMap equipmentEquipInfo(String equip_id){
		NutMap nutMap = new NutMap();
		nutMap.put("equip_id", equip_id);
		return nutMap;
	}
	
	//查询设备配备表
	@At("/findEquipmentEquipInfoById")
	@Ok("json:full")
	public QueryResult findEquipmentEquipInfo(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findEquipmentEquipInfo(nutMap);
	}
	
	//设备选型
	@At("/equipmentInfoSelection")
	@Ok("json")
	public AjaxResult equipmentInfoSelection(@Param("..") DcEquipmentEquipInfo dcEquipmentEquipInfo){
		return dataDesignManagerServiceImpl.equipmentInfoSelection(dcEquipmentEquipInfo);
	}
	
	//查询设计内容相关
	@At("/findDesignContentByProjectId")
	@Ok("json")
	public List <Map> findDesignContentByProjectId(@Param("..") NutMap nutMap){
		return dataDesignManagerServiceImpl.findDesignContentByProjectId(nutMap);
	}
	
	/**
	 * 根据条件查询设计单元信息
	 * @param param
	 * @return
	 */
	@At("/findDesignCellByContentIdAndPhaseId")
	@Ok("json:full")
	public Object findDesignCellByContentIdAndPhaseId(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.findDesignCellByContentIdAndPhaseId(param);
	}
	
	/**
	 * 根据条件查询设计公式
	 * @param param
	 * @return
	 */
	@At("/findDesignFormulaByContentIdAndPhaseId")
	@Ok("json:full")
	public Object findDesignFormulaByContentIdAndPhaseId(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.findDesignFormulaByContentIdAndPhaseId(param);
	}
	
	//打开设计公式排序页面
	@At("/designFormulaSort/?")
	@Ok("beetl:/projectRoot/dcCenter/formula/designFormulaSort.html")
	public NutMap designFormulaSort(String formula_version_id , @Param("name") String name){
		NutMap nutMap = new NutMap();
		nutMap.put("name", name);
		nutMap.put("formula_version_id", formula_version_id);
		return nutMap;
	}
	
	//打开设计单元排序页面
	@At("/designCellSort/?/?/?")
	@Ok("beetl:/projectRoot/dcCenter/variable/designCellSort.html")
	public NutMap designCellSort(String phase_id , String major_id , String content_id , @Param("name") String name){
		NutMap nutMap = new NutMap();
		nutMap.put("phase_id", phase_id);
		nutMap.put("major_id", major_id);
		nutMap.put("content_id", content_id);
		nutMap.put("name", name);
		return nutMap;
	}
	
	/**
	 * 更新设计单元排序规则
	 * @param param
	 * @return
	 */
	@At("/updateDesignCellOrderNum")
	@Ok("json")
	public Object updateDesignCellOrderNum(@Param("order_list") String data_json){
		return dataDesignManagerServiceImpl.updateDesignCellOrderNum(data_json);
	}

	
	/**
	 * 更新设计公式排序规则
	 * @param param
	 * @return
	 */
	@At("/updateDesignFormulaOrderNum")
	@Ok("json")
	public Object updateDesignFormulaOrderNum(@Param("order_list") String data_json){
		return dataDesignManagerServiceImpl.updateDesignFormulaOrderNum(data_json);
	}
	
	
	/**
	 * 合成资料模板库
	 * @return
	 */
	@At("/findDesignTemplate")
	@Ok("json:full")
	public Object findDesignTemplate(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.findDesignTemplate(param);
	}
	
	//更新资料模板
	@At("/updateTemplate")
	@Ok("json")
	public Object updateTemplate(@Param("..") DcTemplateVersion dcDesignTemplate ){
		return dataDesignManagerServiceImpl.updateDesignTemplate(dcDesignTemplate);
	}
	
	//删除合成模板
	@At("/delDesignTemplateById")
	@Ok("json")
	public Object delDesignTemplateById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcTemplateVersion.class, id);
	}
	
	//查询合成模板所需的提入资料信息
	@At("/findMentionDataByTemplate")
	@Ok("json")
	public Object findMentionDataByTemplate(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDaoTemplateVersion().findMentionDataByTemplate(param);
	}
	
	//查询合成模板所需的设计常量信息
	@At("/findConstantDataByTemplate")
	@Ok("json")
	public Object findConstantDataByTemplate(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDaoTemplateVersion().findConstantDataByTemplate(param);
	}
	
	//查询合成模板所需的设计单元信息
	@At("/findDesignCellDataByTemplate")
	@Ok("json")
	public Object findDesignCellDataByTemplate(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDaoTemplateVersion().findDesignCellDataByTemplate(param);
	}
	
	//查询合成模板所需的模板信息
	@At("/findCompoundTemplateByTemplate")
	@Ok("json")
	public Object findCompoundTemplateByTemplate(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDaoTemplateVersion().findCompoundTemplateByTemplate(param);
	}
	
	//查询提出资料合成模板所需的模板信息
	@At("/findPutForWardCompoundTemplateByTemplate")
	@Ok("json")
	public Object findPutForWardCompoundTemplateByTemplate(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDaoTemplateVersion().findPutForWardCompoundTemplateByTemplate(param);
	}
	//查询提出资料合成模板所需的提入资料信息
	@At("/findPutForWardMentionDataByTemplate")
	@Ok("json")
	public Object findPutForWardMentionDataByTemplate(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDaoTemplateVersion().findPutForWardMentionDataByTemplate(param);
	}

	//查询提出资料合成模板所需的设计单元信息
	@At("/findPutForWardDesignCellDataByTemplate")
	@Ok("json")
	public Object findPutForWardDesignCellDataByTemplate(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDaoTemplateVersion().findPutForWardDesignCellDataByTemplate(param);
	}
	
	//查询合成模板库
	@At("/findCompoundTemplate")
	@Ok("json:full")
	public Object findCompoundTemplate(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDaoDcCompoundTemplate().findCompoundTemplate(param);
	}
	
	//删除模板库
	@At("/delCompoundTemplateById")
	@Ok("json")
	public AjaxResult delCompoundTemplateById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcCompoundTemplate.class, id);
	}
	
	//更新合成模板库
	@At("/updateCompoundTemplate")
	@Ok("json")
	public AjaxResult updateCompoundTemplate(@Param("..") DcCompoundTemplate dcCompoundTemplate){
		return dataDesignManagerServiceImpl.updateCompoundTemplate(dcCompoundTemplate);
	}
	
	//更新合成规则
	@At("/updateCompoundRule")
	@Ok("json")
	public AjaxResult updateCompoundRule(@Param("..") DcTemplateVersion dcTemplateVersion){
		return dataDesignManagerServiceImpl.updateCompoundRule(dcTemplateVersion);
	}
	
	//更新合成规则
	@At("/updatePutForWardCompoundRule")
	@Ok("json")
	public AjaxResult updatePutForWardCompoundRule(@Param("..") DcProjectPutFord dcProjectPutFord){
		return dataDesignManagerServiceImpl.updatePutForWardCompoundRule(dcProjectPutFord);
	}

	//模板变量
	@At("/templateVariable/?")
	@Ok("beetl:/projectRoot/dcCenter/templeate/templateVariable.html")
	public NutMap templateVariable(String template_id){
		NutMap nutMap = new NutMap();
		nutMap.put("name","合成模板库");
		nutMap.put("template_id", template_id);
		return nutMap;
	}

	//模板变量数据
	@At("/templateVariableData")
	@Ok("json:full")
	public Object templateVariableData(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getTemplateVariable(param);
	}

	//删除模板变量数据
	@At("/delTemplateVariable/?")
	@Ok("json:full")
	public Object delTemplateVariable(String id){
		return dataDesignManagerServiceImpl.delTemplateVariable(id);
	}

	//获取所有提入资料和设计单元和 设备概算表名
	@At("/getTables")
	@Ok("json:full")
	public List <NutMap> getTables(){
		return dataDesignManagerServiceImpl.getTables();
	}

    //根据表名 查所有字段名
	@At("/getFieldByTableId/?")
	@Ok("json:full")
	public List <NutMap> getFieldByTableId(String tableId){
		return dataDesignManagerServiceImpl.getFieldsByTableId(tableId);
	}


	//更新模板变量数据
	@At("/updateTemplateVariable")
	@Ok("json:full")
	public Object updateTemplateVariable(@Param("..") DcTemplateVariable dcTemplateVariable){
		return dataDesignManagerServiceImpl.updateTemplateVariable(dcTemplateVariable);
	}
	
	//设备id和设备子类型id查找设备
	@At("/findEquipmentByTypeId")
	@Ok("json:full")
	public Object findEquipmentByTypeId(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDaoDcEquipment().findPageDcEquipmentListByEquipmentTypeId(param);
	}
	
	//编辑设备配备信息
	@At("/editEquipmentNum")
	@Ok("json:full")
	public Object editEquipmentNum(@Param("..") DcEquipmentEquipInfo dcEquipmentEquipInfo){
		return dataDesignManagerServiceImpl.editEquipmentNum(dcEquipmentEquipInfo);
	}
	
	//删除设备配备
	@At("/delEquipmentEquipInfoById")
	@Ok("json:full")
	public Object delEquipmentEquipInfoById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcEquipmentEquipInfo.class, id);
	}
	
	//设备概算表维护
	@At("/findEquipmentBudgetList")
	@Ok("json:full")
	public Object findEquipmentBudgetList(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDcEquipmentBudget().findEquipmentBudgetList(param);
	}
	
	//更新设备配备
	@At("/updateEquipmentBudget")
	@Ok("json:full")
	public Object updateEquipmentBudget(@Param("..") DcEquipmentBudget dcEquipmentBudget){
		return dataDesignManagerServiceImpl.updateEquipmentBudget(dcEquipmentBudget);
	}
	
	//删除设备概算表
	@At("/delEquipmentBudgetById/?/?")
	@Ok("json:full")
	public Object delEquipmentBudgetById(String id , String code){
		return dataDesignManagerServiceImpl.delEquipmentBudgetById(id, code);
	}
	
	//分页查询提出资料库
	@At("/findPutForWardList")
	@Ok("json:full")
	public Object findPutForWardList(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDaoDcProjectPutFord().findProjectPutFord(param);
	}
	
	//删除提出资料库
	@At("/delPutForWardById")
	@Ok("json:full")
	public Object delPutForWardById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcProjectPutFord.class, id);
	}
	
	//编辑提出资料
	@At("/updatePutForWard")
	@Ok("json:full")
	public Object updatePutForWard(@Param("..") DcProjectPutFord dcProjectPutFord){
		return dataDesignManagerServiceImpl.updatePutForWard(dcProjectPutFord);
	}
	
	//查询救援设备集
	@At("/findRescueFacility")
	@Ok("json:full")
	public Object findRescueFacility(@Param("..") NutMap param){
		return dataDesignManagerServiceImpl.getDaoDcRescueEquipment().findDcRescueEquipmentList(param);
	}
	
	@At("/delRescueFacilityById")
	@Ok("json:full")
	public AjaxResult delRescueFacilityById(@Param("id") String id){
		return dataDesignManagerServiceImpl.delObj(DcRescueEquipment.class, id);
	}
	
	@At("/updateRescueFacility")
	@Ok("json:full")
	public AjaxResult updateRescueFacility(@Param("..") DcRescueEquipment dcRescueEquipment){
		return dataDesignManagerServiceImpl.updateDcRescueEquipment(dcRescueEquipment);
	}

	//更新动车设施库 或者 插入
	@At("/updateBulletFacility")
	@Ok("json:full")
	public Object updateBulletFacility(@Param("..") DcCRHInfo dcCRHInfo){
		return dataDesignManagerServiceImpl.updateBulletFacility(dcCRHInfo);
	}

	//删除动车设施库
	@At("/delBulletFacilityById")
	@Ok("json:full")
	public Object delBulletFacility(@Param("id") String id){
		return dataDesignManagerServiceImpl.delBulletFacilityById(id);
	}
	
	//打开动车设施库在地图上的标记
	@At("/showMapForBulletFacility")
	@Ok("beetl:/projectRoot/dcCenter/historyDataBase/webgis.html")
	public NutMap showMapForBulletFacility(@Param("x_coord") String x_coord , @Param("y_coord") String y_coord){
		return new NutMap("x_coord",x_coord).addv("y_coord", y_coord);
	}
	
	//动车设施库附件列表
	@At("/affixFile/?")
	@Ok("beetl:/projectRoot/dcCenter/historyDataBase/bulletFacliltyFiles/bulletFacliltyFile.html")
	public NutMap affixFile(String bullet_facility_id){
		//查询附件
		DcCRHInfo dcCRHInfo = daoDcCRHInfo.fetch(bullet_facility_id);
		if(StringUtils.isNotBlank(dcCRHInfo.getCrh_info_attach())){
			DcCrhAttach dcCrhAttach= daoDcCrhAttach.fetch(dcCRHInfo.getCrh_info_attach());
			if(dcCrhAttach != null){
				return new NutMap("data",dcCrhAttach);
			}
		}
		return null;
	}
	
	//更新动车设施库附件信息
	@At("/updateBulletFacilityInfo/?")
	@Ok("json:full")
	public Object updateBulletFacilityInfo(String BulletFacility , @Param("..") DcCrhAttach dcCrhAttach){
		if(StringUtils.isBlank(BulletFacility) || dcCrhAttach == null){
			return AjaxResult.error("更新失败!");
		}
		return dataDesignManagerServiceImpl.updateBulletFacilityInfo(dcCrhAttach, BulletFacility);
	}
	
	//查询车站里程数据库
	@At("/findzzMileageLibrary")
	@Ok("json:full")
	public Object findzzMileageLibrary(@Param("..") NutMap param){
		return daoDcMileageLibrary.findCzMileageLibrary(param);
	}
	
	//删除车站里程数据
	@At("/delzzMileageLibrary/?")
	@Ok("json:full")
	public AjaxResult delzzMileageLibrary(String id){
		return daoDcMileageLibrary.delete(id)==1?AjaxResult.success("删除成功!"):AjaxResult.error("删除失败!");
	}
	
	//更新站站里程数据库
	@POST
	@At("/updatezzMileageLibrary")
	@Ok("json:full")
	public AjaxResult updatezzMileageLibrary(@Param("..") DcMileageLibrary dcMileageLibrary){
		if(StringUtils.isBlank(dcMileageLibrary.getId())){
			//id是否为空
			Object new_obj = daoDcMileageLibrary.insert(dcMileageLibrary);
			return new_obj!=null?AjaxResult.success("更新成功!"):AjaxResult.error("更新失败!");
		}
		return null;
	}

}
